```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>算法精解：两数之和问题</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background-color: #f8f9fa;
            color: #333;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #6e8efb 0%, #4a6cf7 100%);
        }
        .code-block {
            background-color: #2d3748;
            color: #e2e8f0;
            border-radius: 0.5rem;
            overflow: hidden;
        }
        .solution-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .highlight {
            position: relative;
        }
        .highlight::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 30%;
            background-color: rgba(74, 108, 247, 0.2);
            z-index: -1;
            transition: all 0.3s ease;
        }
        .highlight:hover::after {
            height: 100%;
        }
    </style>
</head>
<body class="antialiased overflow-x-hidden">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-5xl px-4">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold mb-4 leading-tight font-serif">
                        两数之和问题
                    </h1>
                    <p class="text-xl md:text-2xl mb-6 opacity-90 leading-relaxed">
                        经典算法问题的优雅解法与深入解析
                    </p>
                    <div class="flex items-center space-x-4">
                        <span class="px-4 py-2 bg-white bg-opacity-20 rounded-full text-sm font-medium">#哈希表</span>
                        <span class="px-4 py-2 bg-white bg-opacity-20 rounded-full text-sm font-medium">#双指针</span>
                        <span class="px-4 py-2 bg-white bg-opacity-20 rounded-full text-sm font-medium">#算法优化</span>
                    </div>
                </div>
                <div class="md:w-1/2 flex justify-center">
                    <div class="w-full max-w-md">
                        <div class="mermaid">
                            graph LR
                            A[问题输入] --> B[数组遍历]
                            B --> C{目标值 - 当前元素}
                            C -->|存在| D[返回索引对]
                            C -->|不存在| E[存入哈希表]
                            E --> B
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Problem Statement Section -->
    <section class="py-16 px-4 bg-white">
        <div class="container mx-auto max-w-5xl">
            <div class="flex flex-col md:flex-row">
                <div class="md:w-2/3 md:pr-10">
                    <h2 class="text-3xl font-bold mb-6 font-serif text-gray-800">
                        题目描述
                        <span class="ml-2 text-blue-500"><i class="fas fa-question-circle"></i></span>
                    </h2>
                    <div class="prose max-w-none text-gray-700">
                        <p class="text-lg leading-relaxed mb-6">
                            给定一个整数数组和一个目标值，找出数组中两个数字，使它们相加等于目标值。假设每个输入都有唯一解，同一个元素不能使用两次。
                        </p>
                        <p class="text-lg leading-relaxed mb-6">
                            例如，给定数组 <code class="bg-gray-100 px-2 py-1 rounded">[2, 7, 11, 15]</code> 和目标值 <code class="bg-gray-100 px-2 py-1 rounded">9</code>，因为 <code class="bg-gray-100 px-2 py-1 rounded">2 + 7 = 9</code>，所以返回 <code class="bg-gray-100 px-2 py-1 rounded">[0, 1]</code>（这两个数字的索引）。
                        </p>
                    </div>
                </div>
                <div class="md:w-1/3 mt-8 md:mt-0">
                    <div class="bg-blue-50 rounded-xl p-6 border border-blue-100">
                        <h3 class="text-xl font-bold mb-4 text-blue-700 flex items-center">
                            <i class="fas fa-lightbulb mr-2"></i> 关键提示
                        </h3>
                        <ul class="space-y-3 text-blue-800">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-blue-500 mt-1 mr-2"></i>
                                <span>每个输入都有唯一解</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-blue-500 mt-1 mr-2"></i>
                                <span>同一个元素不能使用两次</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-blue-500 mt-1 mr-2"></i>
                                <span>需要返回原始索引而非元素值</span>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Solutions Section -->
    <section class="py-16 px-4 bg-gray-50">
        <div class="container mx-auto max-w-5xl">
            <h2 class="text-3xl font-bold mb-12 text-center font-serif text-gray-800">
                解决方案
                <span class="ml-2 text-blue-500"><i class="fas fa-code"></i></span>
            </h2>
            
            <div class="grid md:grid-cols-2 gap-8">
                <!-- Hash Map Solution -->
                <div class="solution-card bg-white rounded-xl shadow-md overflow-hidden transition-all duration-300">
                    <div class="bg-blue-600 px-6 py-4 flex items-center">
                        <div class="w-10 h-10 rounded-full bg-white bg-opacity-20 flex items-center justify-center mr-4">
                            <i class="fas fa-hashtag text-white"></i>
                        </div>
                        <h3 class="text-xl font-bold text-white">哈希表解法</h3>
                    </div>
                    <div class="p-6">
                        <div class="mb-6">
                            <h4 class="font-bold text-lg mb-3 text-gray-800 flex items-center">
                                <i class="fas fa-brain mr-2 text-blue-500"></i> 解题思路
                            </h4>
                            <p class="text-gray-700 leading-relaxed">
                                遍历数组，对于每个元素 <code class="bg-gray-100 px-1 py-0.5 rounded">nums[i]</code>，检查 <code class="bg-gray-100 px-1 py-0.5 rounded">target - nums[i]</code> 是否在哈希表中。若存在，则返回对应的索引对；若不存在，将 <code class="bg-gray-100 px-1 py-0.5 rounded">nums[i]</code> 及其索引存入哈希表。
                            </p>
                        </div>
                        
                        <div class="mb-6">
                            <h4 class="font-bold text-lg mb-3 text-gray-800 flex items-center">
                                <i class="fas fa-stopwatch mr-2 text-blue-500"></i> 复杂度分析
                            </h4>
                            <div class="flex justify-between text-sm">
                                <div class="text-center">
                                    <div class="bg-blue-100 text-blue-800 px-3 py-2 rounded-lg">
                                        <div class="font-bold">时间复杂度</div>
                                        <div>O(n)</div>
                                    </div>
                                </div>
                                <div class="text-center">
                                    <div class="bg-purple-100 text-purple-800 px-3 py-2 rounded-lg">
                                        <div class="font-bold">空间复杂度</div>
                                        <div>O(n)</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        
                        <div>
                            <h4 class="font-bold text-lg mb-3 text-gray-800 flex items-center">
                                <i class="fas fa-code mr-2 text-blue-500"></i> 示例代码
                            </h4>
                            <div class="code-block p-4 rounded-lg">
                                <pre class="overflow-x-auto text-sm"><code class="language-python">def twoSum(nums, target):
    hash_map = {}
    for i, num in enumerate(nums):
        if target - num in hash_map:
            return [hash_map[target - num], i]
        hash_map[num] = i
    return []</code></pre>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- Two Pointers Solution -->
                <div class="solution-card bg-white rounded-xl shadow-md overflow-hidden transition-all duration-300">
                    <div class="bg-indigo-600 px-6 py-4 flex items-center">
                        <div class="w-10 h-10 rounded-full bg-white bg-opacity-20 flex items-center justify-center mr-4">
                            <i class="fas fa-arrows-alt-h text-white"></i>
                        </div>
                        <h3 class="text-xl font-bold text-white">双指针解法</h3>
                    </div>
                    <div class="p-6">
                        <div class="mb-6">
                            <h4 class="font-bold text-lg mb-3 text-gray-800 flex items-center">
                                <i class="fas fa-brain mr-2 text-indigo-500"></i> 解题思路
                            </h4>
                            <p class="text-gray-700 leading-relaxed">
                                先对数组排序，然后使用两个指针（左右指针）从两端向中间移动，寻找和为目标值的元素对。<span class="highlight font-medium">注意：</span>由于题目要求返回原始索引，此方法需要进行额外处理。
                            </p>
                        </div>
                        
                        <div class="mb-6">
                            <h4 class="font-bold text-lg mb-3 text-gray-800 flex items-center">
                                <i class="fas fa-stopwatch mr-2 text-indigo-500"></i> 复杂度分析
                            </h4>
                            <div class="flex justify-between text-sm">
                                <div class="text-center">
                                    <div class="bg-blue-100 text-blue-800 px-3 py-2 rounded-lg">
                                        <div class="font-bold">时间复杂度</div>
                                        <div>O(n log n)</div>
                                    </div>
                                </div>
                                <div class="text-center">
                                    <div class="bg-purple-100 text-purple-800 px-3 py-2 rounded-lg">
                                        <div class="font-bold">空间复杂度</div>
                                        <div>O(1)*</div>
                                    </div>
                                </div>
                            </div>
                            <p class="text-xs text-gray-500 mt-2">* 不考虑排序所需的额外空间</p>
                        </div>
                        
                        <div>
                            <h4 class="font-bold text-lg mb-3 text-gray-800 flex items-center">
                                <i class="fas fa-code mr-2 text-indigo-500"></i> 示例代码
                            </h4>
                            <div class="code-block p-4 rounded-lg">
                                <pre class="overflow-x-auto text-sm"><code class="language-python">def twoSum(nums, target):
    # 创建包含原始索引的元组列表
    nums_with_index = [(num, i) for i, num in enumerate(nums)]
    # 按数值排序
    nums_with_index.sort()
    left, right = 0, len(nums) - 1
    while left < right:
        current_sum = nums_with_index[left][0] + nums_with_index[right][0]
        if current_sum == target:
            return sorted([nums_with_index[left][1], nums_with_index[right][1]])
        elif current_sum < target:
            left += 1
        else:
            right -= 1
    return []</code></pre>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Comparison Section -->
    <section class="py-16 px-4 bg-white">
        <div class="container mx-auto max-w-5xl">
            <h2 class="text-3xl font-bold mb-12 text-center font-serif text-gray-800">
                方法对比
                <span class="ml-2 text-blue-500"><i class="fas fa-balance-scale"></i></span>
            </h2>
            
            <div class="overflow-x-auto">
                <table class="min-w-full bg-white rounded-lg overflow-hidden">
                    <thead>
                        <tr class="bg-gray-100 text-gray-700">
                            <th class="py-3 px-4 text-left font-bold">维度</th>
                            <th class="py-3 px-4 text-left font-bold">哈希表法</th>
                            <th class="py-3 px-4 text-left font-bold">双指针法</th>
                        </tr>
                    </thead>
                    <tbody class="divide-y divide-gray-200">
                        <tr>
                            <td class="py-3 px-4 font-medium">时间复杂度</td>
                            <td class="py-3 px-4">O(n) - 线性</td>
                            <td class="py-3 px-4">O(n log n) - 受排序影响</td>
                        </tr>
                        <tr class="bg-gray-50">
                            <td class="py-3 px-4 font-medium">空间复杂度</td>
                            <td class="py-3 px-4">O(n) - 需要哈希表</td>
                            <td class="py-3 px-4">O(1) - 原地操作</td>
                        </tr>
                        <tr>
                            <td class="py-3 px-4 font-medium">适用场景</td>
                            <td class="py-3 px-4">通用，无需排序</td>
                            <td class="py-3 px-4">已排序或可排序数组</td>
                        </tr>
                        <tr class="bg-gray-50">
                            <td class="py-3 px-4 font-medium">索引处理</td>
                            <td class="py-3 px-4">直接保留原始索引</td>
                            <td class="py-3 px-4">需要额外记录索引</td>
                        </tr>
                    </tbody>
                </table>
            </div>
            
            <div class="mt-12 bg-yellow-50 border-l-4 border-yellow-400 p-4 rounded-r-lg">
                <div class="flex">
                    <div class="flex-shrink-0">
                        <i class="fas fa-exclamation-circle text-yellow-500 text-xl mt-1"></i>
                    </div>
                    <div class="ml-3">
                        <h3 class="text-lg font-medium text-yellow-800">注意事项</h3>
                        <p class="mt-1 text-yellow-700">
                            虽然双指针法在空间复杂度上有优势，但在LeetCode等编程题目中，由于通常需要返回原始索引，哈希表法往往是更直接的选择。双指针法更适合仅需返回值而非索引的情况，或数组已排序的场景。
                        </p>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Visualization Section -->
    <section class="py-16 px-4 bg-gray-50">
        <div class="container mx-auto max-w-5xl">
            <h2 class="text-3xl font-bold mb-12 text-center font-serif text-gray-800">
                算法可视化
                <span class="ml-2 text-blue-500"><i class="fas fa-project-diagram"></i></span>
            </h2>
            
            <div class="grid md:grid-cols-2 gap-8 items-center">
                <div>
                    <div class="mermaid">
                        graph TD
                        A[输入数组: 2,7,11,15] --> B[目标值: 9]
                        B --> C[初始化哈希表]
                        C --> D[遍历数组]
                        D --> E{9-2=7 在哈希表?}
                        E -->|否| F[存入 2:0]
                        D --> G{9-7=2 在哈希表?}
                        G -->|是| H[返回 [0,1]]
                    </div>
                </div>
                <div>
                    <div class="bg-white p-6 rounded-xl shadow-md">
                        <h3 class="text-xl font-bold mb-4 text-gray-800">哈希表执行过程</h3>
                        <ol class="list-decimal pl-5 space-y-3 text-gray-700">
                            <li>初始化空哈希表：<code class="bg-gray-100 px-1 py-0.5 rounded">{}</code></li>
                            <li>访问第一个元素2：计算9-2=7 → 哈希表中无7 → 存入{2:0}</li>
                            <li>访问第二个元素7：计算9-7=2 → 哈希表中有2 → 返回[0,1]</li>
                        </ol>
                        <div class="mt-6 p-4 bg-green-50 rounded-lg border border-green-200">
                            <div class="flex items-center">
                                <i class="fas fa-check-circle text-green-500 mr-2"></i>
                                <span class="font-medium">找到解：索引0(值2) + 索引1(值7) = 9</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```